/*
 * @(#)FileRename.java		       version: 0.1 
 * Date:2012-2-22
 *
 * Copyright (c) 2011 CFuture09, Institute of Software, 
 * Guangdong Ocean University, Zhanjiang, GuangDong, China.
 * All rights reserved.
 */
package com.sinaapp.msdxblog.tools.file;

import java.io.File;

/**
 * @author Geek_Soledad (66704238@51uc.com)
 */
public class FileRename {

	public static void main(String[] args) {
		String path = "E:/androidApk/2012/02/每周囧图/第1期/backup";
		renameFiles(path);
	}
	
	public static void renameFiles(String dirPath) {
		File dir = new File(dirPath);
		if (!dir.isDirectory()) {
			return ;
		}
		File[] files = dir.listFiles();
		for (int i = 0, length = files.length; i < length; i++) {
			String ext = files[i].getName().substring(files[i].getName().lastIndexOf("."));
			File file = new File(dir + File.separator + "p" + i + ext);
//			System.out.println(file.getAbsolutePath());
//			System.out.println(files[i]);
			files[i].renameTo(file);
		}
	}
}
